package com.gesee.zyspps.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.gesee.zys.R;

public class DialogAdapter extends BaseAdapter
{

    private Context context;
    private List<String> dialogList;

    public DialogAdapter(Context context)
    {
        this.context = context;
    }

    public void setList(List<String> dialogList)
    {
        this.dialogList = dialogList;
    }

    @Override
    public int getCount()
    {
        return dialogList.size();
    }

    @Override
    public Object getItem(int position)
    {
        return dialogList.get(position);
    }

    @Override
    public long getItemId(int position)
    {
        return position;
    }

    @Override
    public View getView(int position, View covertView, ViewGroup parent)
    {
        ViewHolder holder = null;
        if (covertView == null)
        {
            covertView = LayoutInflater.from(context).inflate(R.layout.style_dialog, null);
            holder = new ViewHolder();
            holder.name = (TextView) covertView.findViewById(R.id.styleName);
            covertView.setTag(holder);
        }
        else
        {
            holder = (ViewHolder) covertView.getTag();
        }
        holder.name.setText(dialogList.get(position));
        return covertView;
    }

    class ViewHolder
    {
        TextView name;
    }
}
